export function createParams(val) {
	const newVal = {};
	for (let key in val) {
		if (val.hasOwnProperty(key)) {
			newVal['P_' + key.toUpperCase()] = val[key];
		}
	}
	return newVal;
}

export function pinToTop() {
	uni.pageScrollTo({
		scrollTop: 0,
		duration: 0
	});
}

export function isHeaderClass() {
	if (process.env.UNI_PLATFORM === 'app-plus' || process.env.UNI_PLATFORM === 'h5' || process.env.UNI_PLATFORM === 'app') {
		return 'header-class-app'; // 应用App平台和H5的样式
	} else if (process.env.UNI_PLATFORM === 'mp-weixin') {
		return 'header-class-wechat'; // 应用微信小程序的样式
	}
}


export function generateUUID () {
	let d = new Date().getTime();
	const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
		const r = (d + Math.random() * 16) % 16 | 0;
		d = Math.floor(d / 16);
		return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
	});
	return uuid;
}

export function generateUUID16 () {
	let d = new Date().getTime();
	const uuid = 'xxxxxxxx-xxxx-4xxx'.replace(/[xy]/g, function(c) {
		const r = (d + Math.random() * 16) % 16 | 0;
		d = Math.floor(d / 16);
		return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
	});
	return uuid;
}